package com.example.duomeitijuhe.ui;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.ImageButton;
import com.example.duomeitijuhe.R;
import com.example.duomeitijuhe.others.ActivityCollector;
import com.example.duomeitijuhe.others.ReducePicture;
import com.example.duomeitijuhe.others.RoundPicture;

/**
 * Created by Michael on 2014/10/14.
 */
public class MyselfEditActivity extends Activity implements View.OnClickListener{

    private ImageButton headImageButton;
    private Button myPlatformButton;
    private Button exitCurrentAccoutButton;
    private Button exitDuoMeiTiButton;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        Log.v("MyselfEditActivity","到这了哦myself");
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.my_self_edit);
        ActivityCollector.addActivity(this);
        Log.e("eroor","error");
        initData();

        Bitmap bitmap = initHeadImageButton();
        headImageButton.setImageBitmap(bitmap);
        myPlatformButton.setOnClickListener(this);
        exitDuoMeiTiButton.setOnClickListener(this);
        exitCurrentAccoutButton.setOnClickListener(this);
    }

    public void initData(){
        headImageButton = (ImageButton)findViewById(R.id.my_head_image_button);
        myPlatformButton = (Button)findViewById(R.id.my_platform_button);
        exitCurrentAccoutButton = (Button)findViewById(R.id.exit_current_account_button);
        exitDuoMeiTiButton = (Button)findViewById(R.id.exit_duomeitijuhe_button);
    }

    public Bitmap initHeadImageButton(){
        ReducePicture reducePicture = new ReducePicture(MyselfEditActivity.this);
        Bitmap bitmap = reducePicture.pictureToLess(R.drawable.default_head_icon,50);
        RoundPicture roundPicture = new RoundPicture();
        Bitmap bitmap1 = roundPicture.toRoundBitmap(bitmap);
        return bitmap1;
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.my_head_image_button:
                break;
            case R.id.my_platform_button:
                Intent intent = new Intent(MyselfEditActivity.this,PlatformBindActivity.class);
                startActivity(intent);
                break;
            case R.id.exit_current_account_button:
                ActivityCollector.finishAll();
                finish();
                Intent intent1 = new Intent(MyselfEditActivity.this,LoginActivity.class);
                startActivity(intent1);
                break;
            case R.id.exit_duomeitijuhe_button:
                ActivityCollector.finishAll();
                finish();
                break;
            default:
                break;
        }
    }
}
